package com.sentrix.auto.printercenter.common;

import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.Objects;

public class ResMsgUtils {
    //消息是打印机、打印Job
    public static final String PRINTER = "PRINTER";
    //是否是事件
    public static final String EVENT = "event";


    /**
     * 判断消息是否是打印机消息，
     *  true:打印机消息
     *  false:打印任务消息
     *  null: 其他消息
     * @param resMsg
     * @return
     */
    public static Boolean isPrinter(Map<String, Object> resMsg) {
        if (!resMsg.containsKey("type") || Objects.isNull(resMsg.get("type")) || StringUtils.isBlank((String) resMsg.get("type"))) {
            return null;
        }
        return StringUtils.equals(String.valueOf(resMsg.get("type")), PRINTER);
    }

    public static boolean isEvent(Map<String, Object> resMsg) {
        return resMsg.containsKey(EVENT);
    }

}
